package com.wenjie.shoprankmonitor;

import java.io.IOException;
import java.util.List;

import javax.jdo.PersistenceManager;
import javax.servlet.http.*;

@SuppressWarnings("serial")
public class Shop_Rank_MonitorServlet extends HttpServlet {
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		resp.setContentType("text/plain");
		String str = "helloS2";
		resp.getWriter().println(str);

        PersistenceManager pm = PMF.get().getPersistenceManager();
        String query = "select from " + User.class.getName();
        List<User> results = (List<User>) pm.newQuery(query).execute();
        
        if(results.isEmpty()) {
        	str = "Empty";
        	resp.getWriter().println(str);
        } else {
        	for(User s : results) {
        		if(s.getPassword() != null) {
        			resp.getWriter().println(s.getPassword());
        		} else {
        			resp.getWriter().println("no pwd");
        		}
        		pm.deletePersistent(s);
        	}
        }
        pm.close();
	}
}
	